package com.cvnert.testplatform.controller;


import com.cvnert.testplatform.domain.vo.TaskVo;
import com.cvnert.testplatform.domain.vo.TestCaseListVo;
import com.cvnert.testplatform.domain.vo.TestCaseVo;
import com.cvnert.testplatform.service.TaskService;
import com.cvnert.testplatform.service.TestCaseService;
import com.cvnert.testplatform.utils.ResultJson;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/case")
public class TestController {
    @Resource
    private TestCaseService testCaseService;

    @PostMapping("/add")
    public ResultJson<Object> getTaskList(@RequestBody TestCaseVo testCaseVo){
        return ResultJson.success(testCaseService.addTestCase(testCaseVo));
    }

    @GetMapping("/delete/{cid}")
    public ResultJson<Object> deleteTask(@PathVariable Integer cid){
        return ResultJson.success(testCaseService.deleteTestCase(cid));
    }

    @PostMapping("/update")
    public ResultJson<Object> updateTask(@RequestBody TestCaseVo testCaseVo){
        return ResultJson.success(testCaseService.updateTestCase(testCaseVo));
    }

    @PostMapping("/list")
    public ResultJson<Object> getTaskList(@RequestBody TestCaseListVo testCaseListVo){
        return ResultJson.success(testCaseService.getTestCaseList(testCaseListVo));
    }

    @GetMapping("/detail/{cid}")
    public ResultJson<Object> getTaskDetail(@PathVariable Integer cid){
        return ResultJson.success(testCaseService.getTestCaseDetail(cid));
    }

    @PostMapping("/count")
    public ResultJson<Object> getDefectCount(@RequestBody TestCaseListVo testCaseListVo){
        return ResultJson.success(testCaseService.getDefectCount(testCaseListVo));
    }
}
